const mutations = {
    //添加购物车商品
    pushShopCarGood(state, item) {
        state.shopCarGoods.push(item);
    },

    //增加购物车商品数量
    incrementItemQuantity(state, item) {
        const findItem = state.shopCarGoods.find(element => item.iid === element.iid);
        findItem.quantity += 1;
    },

    //修改该商品是否被选中
    changeItemChecked(state, item) {
        const findItem = state.shopCarGoods.find(element => item.iid === element.iid);
        findItem.isChecked = !findItem.isChecked;
    },

    //修改全选按钮状态
    changeIsChooseAll(state, payload) {
        state.isChooseAll = payload
    },

    //切换全选购物车商品
    tabGoodsChoseAll(state) {
        state.isChooseAll = !state.isChooseAll;
        state.shopCarGoods.forEach(element => {
            element.isChecked = state.isChooseAll;
        })
    }
}

export default mutations;